﻿<?php

require('../configs/include.php');

class c_personaje extends super_controller {
    
    
    public function mostrardatos() {
         $datos = array();
         $datos['Nombre']=$this->post->Nombre;
         $datos['Descripcion']=$this->post->Descripcion;
         $datos['Comportamiento']=$this->post->Comportamiento;
         $datos['Tipo']=$this->post->Tipo;
         $datos['Habilidad']=$this->post->Habilidad;

         $this->engine->assign('Personaje',$datos );
    }
     public function SeleccionarVidejuego(){
       $options['videojuego']['lvl2'] = "nombre";
        $this->orm->connect();
        $this->orm->read_data(array("videojuego"), $options);
        $videojuego = $this->orm->get_objects("videojuego");
        $this->orm->close();
        $this->engine->assign('videojuego', $videojuego);
           
          }
          public function registrar(){
            $personaje = new personaje($this->post);
            $options = "normal";
            $this->orm->connect();
            $this->orm->insert_data($options, $personaje);
            $this->orm->close();

            $this->type_warning = "success";
            $this->msg_warning = "el item se guardo";
            $this->engine->assign('type_warning', $this->type_warning);
            $this->engine->assign('msg_warning', $this->msg_warning);
            $this->temp_aux = 'message.tpl';
          } 

    public function display() {	
            $this->SeleccionarVidejuego();
            $this->engine->assign('title',$this->pantallazo);
            $this->engine->display('header.tpl');
            
            if ($this->error == 1) {
            $this->engine->assign('obj', $this->post);
            $this->engine->assign('type_warning', $this->type_warning);
            $this->engine->assign('msg_warning', $this->msg_warning);
            $this->temp_aux = 'message.tpl';
        }
        $this->engine->display($this->temp_aux);
            
            $this->engine->display('crear_personaje.tpl'); 
            $this->engine->display('footer.tpl');
    }

    public function run() {
           try {
            if (isset($this->get->option)) {
                $this->{$this->get->option}();
            }
        } catch (Exception $e) {
            $this->error = 1;
            $this->msg_warning = $e->getMessage();
        }
        $this->display();
        
    }

}

$call = new c_personaje();
$call->run();

?>